/*
 * @Description: 用户相关状态存储，包含用户基本信息和用户是否登录
 * @Author: 熊伟
 * @LastEditors: 黄勇
 * @Date: 2019-04-08 09:15:47
 * @LastEditTime: 2020-04-08 11:27:03
 */

import _this from '@/main.js';

const mutationTypes = {
    SET_USERINFO: 'SET_USERINFO',           // 设置/更新 用户信息数据
    SET_LOGINSTATE: 'SET_LOGINSTATE',       // 设置用户登录状态
    SET_LOGINLAYOUT: "SET_LOGINLAYOUT",
    CLEAR_ACCOUNT: "CLEAR_ACCOUNT",
    SET_SESSIONID: "SET_SESSIONID",
}

const actionTypes = {
}

const state = {
    isLogin: false,
    userInfo: {},
    isShowLoginLayout: false,
    sessionId: "",
}

const getters = {
    
}

const mutations = {
    [mutationTypes.SET_USERINFO](state, param) {
        state.userInfo = Object.assign({}, param);
    },
    [mutationTypes.SET_LOGINSTATE](state, param) {
        state.isLogin = param.isLogin;
    },
    [mutationTypes.SET_LOGINLAYOUT](state, param) {
        state.isShowLoginLayout = param;
    },
    [mutationTypes.CLEAR_ACCOUNT](state) {
        state.userInfo = {}
    },
    [mutationTypes.SET_SESSIONID](state, id) {
        state.sessionId = id
    }
}

const actions = {
   
}

export default {
    state,
    getters,
    mutations,
    actions,
    mutationTypes,
    actionTypes,
    namespaced: true,
}